package com.ophiux.cs.domain.consult.model.factory;

import com.ophiux.cs.domain.consult.model.entity.CSUser;
import com.ophiux.utils.common.DateUtil;
import com.ophiux.utils.common.StringUtil;
import com.ophiux.utils.exception.OphiuxParamException;

/**
 * 咨询用户构造器
 * @author chenh
 *
 */
public class CSUserBuilder {
	
	private static CSUserBuilder csUserBuilder;
	
	public static CSUserBuilder getInstance() {
		if(csUserBuilder == null) {
			csUserBuilder = new CSUserBuilder();
		}
		return csUserBuilder;
	}

	public CSUser build(String TARGET_ACC,String TARGET_NAME,String SEX,
			String ROLE,String PHOTO_URL) throws OphiuxParamException{
		
		CSUser csUser = new CSUser();
		
		if(StringUtil.isEmpty(TARGET_ACC)) throw new OphiuxParamException("账号不能为空");
		
		if(StringUtil.isEmpty(TARGET_NAME)) throw new OphiuxParamException("昵称不能为空");
		
		csUser.setTARGET_ACC(TARGET_ACC);
		csUser.setTARGET_NAME(TARGET_NAME);
		csUser.setTARGET_ID(createCSTargetID());//生成账号ID
		
		csUser.setPHOTO_URL(PHOTO_URL);
		csUser.setROLE(ROLE);
		csUser.setSEX(SEX);
		
		//注册时间
		csUser.setREG_DATE(DateUtil.getCurDateStr());
		//状态为有效
		csUser.toValid();
		
		return csUser;
	}
	
	/**
	 * 用户ID生成方法
	 * @return
	 */
	public synchronized String createCSTargetID() {
		
		String targetID = "";
		
		return targetID;
	}
	
}
